package com.glasses.pandora.service;

import com.glasses.pandora.Mock;
import com.glasses.pandora.domain.Report;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Jean-Luc Burot
 * @since 2014-09-30
 */
@Stateless
public class ReportService {
    @PersistenceContext(unitName = "AbcPU")
    EntityManager em;
    
    private void save(Object object) {
        try {
            em.persist(object);
        } catch (Exception ex) {
            System.err.println("Error trying to save:");
            System.err.println(ex.getMessage());
        }
    }
    
    public void saveReport(Report report) {
        save(report);
    }
    
    public List<Report> findAllReports() {
        return Mock.getReports();
    }
    
    public Report findReport(Long id) {
        return Mock.getReport(id);
    }
}
